/**
 * 系统设置权限设置添加管理员
 */
import './index.less'
import tem from './index.html'
import $_fn from '~plugins'
class confirmCtrl {
  constructor($scope,$rootScope,http,$ui) {
  	  console.log($scope.params)
      $scope.cancel = function () {
          $rootScope.$uiDirectiveModal.close() //关闭方法
      }
  	  //初始化参数
  	  $scope.param1={
  	  	payId:JSON.parse($scope.params).payId
  	  }
  	  //订单信息请求
  	  $scope.xinXi=function(){
  	  	http.post('confirmRepayment.do',$scope.param1,function (data) {
				if(data.errcode==1){
					$ui.toast({
						text:data.errmsg,
						type:'succeed',
						appendTo:'.confirm'
					})
					$scope.param2=data.data[0];
					$scope.$apply()
				}else{
					$ui.toast({
						text:data.errmsg,
						type:'warning',
						appendTo:'.confirm'
					})
				}
	        },function(_data){
	            console.log(_data);//报错
	      	})
  	  }
  	  $scope.xinXi()
  		//确定到账
  	  $scope.tiJiao1=function(){
  	  		console.log('确定收款')
  	  		http.post('confirmationAccount.do',{pay_id:JSON.parse($scope.params).payId},function (data) {
				if(data.type==1){
					$ui.toast({
						text:data.msg,
						type:'succeed',
						appendTo:'.confirm'
					})
					$scope.cancel()//关闭弹窗
					//window.history.go(0)
				}else{
					$ui.toast({
						text:data.msg,
						type:'warning',
						appendTo:'.confirm'
					})
				}
	        },function(_data){
	            console.log(_data);//报错
	      	})
  	  }
  	  	//取消收款
  	  $scope.tiJiao2=function(){
  	  		console.log('取消收款')
  	  		http.post('cancelPayment.do',{pay_id:JSON.parse($scope.params).payId},function (data) {
				if(data.type==1){
					$ui.toast({
						text:data.msg,
						type:'succeed',
						appendTo:'.confirm'
					})
					$scope.cancel()//关闭弹窗
					//window.history.go(0)
				}else{
					$ui.toast({
						text:data.msg,
						type:'warning',
						appendTo:'.confirm'
					})
				}
	        },function(_data){
	            console.log(_data);//报错
	      	})
  	  }
  }
}
confirmCtrl.$inject = ['$scope','$rootScope','http','$ui']
module.exports = angular.module('directive.confirm', []).directive('confirm', function() {
    return {
        template: tem,
        replace:true,
        controller: confirmCtrl,
        scope:{
        	params:"@"
        }
    }
}).name